package org.linlinjava.litemall.db.service;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LitemallRewardRuleConfigMapper;
import org.linlinjava.litemall.db.domain.LitemallRewardRuleConfig;
import org.linlinjava.litemall.db.domain.LitemallRewardRuleConfigExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: litemall
 * @description: litemall_reward_rule
 * @author: chenyu
 * @create: 2022-03-15 10:59
 **/
@Service
public class LitemallRewardRuleConfigService extends MPJBaseServiceImpl<LitemallRewardRuleConfigMapper,LitemallRewardRuleConfig> {
  @Resource
  private LitemallRewardRuleConfigMapper litemallRewardRuleConfigMapper;

  public void add(LitemallRewardRuleConfig config){
    litemallRewardRuleConfigMapper.insert(config);
  }

  public void delete(Integer configId){
    litemallRewardRuleConfigMapper.deleteByPrimaryKey(configId);
  }

  public void update(LitemallRewardRuleConfig config){
    litemallRewardRuleConfigMapper.updateByPrimaryKeySelective(config);
  }

  public List<LitemallRewardRuleConfig> list(LitemallRewardRuleConfigExample example){
    return litemallRewardRuleConfigMapper.selectByExample(example);
  }

  public List<LitemallRewardRuleConfig> listByRuleId(Integer ruleId){
    LitemallRewardRuleConfigExample example = new LitemallRewardRuleConfigExample();
    example.or().andRewardRuleIdEqualTo(ruleId);
    return litemallRewardRuleConfigMapper.selectByExample(example);
  }

  public List<LitemallRewardRuleConfig> listByRuleIdAndNum(Integer ruleId,Integer num){
    LitemallRewardRuleConfigExample example = new LitemallRewardRuleConfigExample();
    example.or().andRewardRuleIdEqualTo(ruleId).andPerNumEqualTo(num);
    return litemallRewardRuleConfigMapper.selectByExample(example);
  }


}
